package com.wwg.market.ui.dashboard.client.utils;

import com.nexustar.gwt.widgets.client.asyn.LoadingAsyncCallback;
import com.wwfish.gwt.model.client.ILoadModelProvider;
import com.wwfish.gwt.model.client.IModelCallback;
import com.wwfish.gwt.model.client.impl.FishModelManager;
import com.wwg.market.ui.dashboard.client.Utils;
import com.wwg.market.ui.service.interfaces.CategoryService;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-12-17
 * Time: 8:29:34
 * To change this template use File | Settings | File Templates.
 */
public class AppModelCooker {
    public static void initAppModel() {
        initChannelModel();
    }

    private static void initChannelModel() {
        FishModelManager.createAppModel("channels", FishModelManager.TYPE_LIST, new ILoadModelProvider() {
            public void getModel(Object[] parameters, final IModelCallback iModelCallback) {
                Utils.invoke(CategoryService.class.getName(), "getAllCategory", null, new LoadingAsyncCallback() {
                    @Override
                    protected void success(Object result) {
                        iModelCallback.setFishModel(result);
                    }
                });
            }
        }).loadByProvider(null);
    }
}
